﻿@model PhoneBilling.Models.UserEditModel
@{
    ViewBag.Title = "用户编辑";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnConfirm").ligerButton(
        {
            click: function () {
                changeAreaType();
                $('form').submit();
            }
        });
    });
    
</script>
@using (Html.BeginForm())
{ 
    <div class="system_input_contain">
        @Html.HiddenFor(m => m.ID)
        @Html.HiddenFor(m => m.IsNew)
        @Html.LabelFor(m => m.Name)
        @Html.TextBoxFor(m => m.Name)
        @Html.ValidationMessageFor(m => m.Name, new { style = "color:Red" })
    </div>
    if (Model.IsNew)
    {
        <div class="system_input_contain">
            @Html.LabelFor(m => m.Password)
            @Html.TextBoxFor(m => m.Password)
            @Html.ValidationMessageFor(m => m.Password, new { style = "color:Red" })
        </div>
    }
    
    <div class="system_input_contain">
        @Html.LabelFor(m => m.Authority)
        <div class="system_input_group">
            @Html.HiddenFor(m => m.Authority, new { id = "authority" })
            @for (int i = 0; i < Model.AuthorityList.Count; i++)
            {
                <div class="system_checkbox authority_checkbox">
                    @Html.CheckBoxFor(m => m.AuthorityList[i].Allow, new { @class = "authority", id = Model.AuthorityList[i].Item })
                    @Html.Label(string.Format(" {0} ", Model.AuthorityList[i].Item))
                </div>
            }
        </div>
    </div>
    <div class="system_input_contain">
        <input type="button" id="btnConfirm" value="确定" />
        @*<input type="submit" value="确定" class="input-submit" onclick="changeAreaType();" />*@
    </div>
}
<script type="text/javascript">
    function changeAreaType() {
        var str = "";
        $(".authority").each(function () {
            if ($(this).attr("checked") == "checked") {
                if (str == "") {
                    str += $(this).attr("id");
                }
                else {
                    str += ";" + $(this).attr("id");
                }
            }
        });
        $("#authority").val(str);
    }
</script>
